﻿using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PPP.Model.FormatWrapper {
    /// <summary>
    /// Model to handel the printers.
    /// 
    /// <list type="bullet">
    /// <item>
    /// <term>Author</term>
    /// <description>Sebastian Will</description>
    /// </item>
    /// </list>
    /// 
    /// </summary> 
    public class PrinterFormatWrapper {
        #region Fields

        /// <summary>
        /// The name of the printer.
        /// </summary>
        string _name = string.Empty;

        /// <summary>
        /// Is the printer the default printer.
        /// </summary>
        bool _isDefault = false;

        /// <summary>
        /// Is the printer valid.
        /// </summary>
        string _isValid = "";

        /// <summary>
        /// The uri of the icon.
        /// </summary>
        Uri _icon = null;

        /// <summary>
        /// The different paper sizes of the printer.
        /// </summary>
        List<PaperSizeFormatWrapper> _paperSizes = null;

        #endregion

        #region Properties

        /// <summary>
        /// The name of the printer.
        /// </summary>
        public string Name {
            get {
                return _name;
            }
        }

        /// <summary>
        /// Is the printer the default printer.
        /// </summary>
        public bool IsDefault {
            get {
                return _isDefault;
            }
        }

        /// <summary>
        /// Is the printer is valid.
        /// </summary>
        public string IsValid {
            get {
                return _isValid;
            }
        }

        /// <summary>
        /// The uri of the icon.
        /// </summary>
        public Uri Icon {
            get {
                return _icon;
            }
        }

        /// <summary>
        /// The different paper sizes of the printer.
        /// </summary>
        public List<PaperSizeFormatWrapper> PaperSizes {
            get {
                if (_paperSizes == null)
                    _paperSizes = new List<PaperSizeFormatWrapper>();
                return _paperSizes;
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Construktor.
        /// </summary>
        /// <param name="printerSettings">The printer settings of the printer.</param>
        public PrinterFormatWrapper(PrinterSettings printerSettings) {
            _name = printerSettings.PrinterName;
            _isDefault = printerSettings.IsDefaultPrinter;

            foreach (PaperSize paperSize in printerSettings.PaperSizes) {
                PaperSizes.Add(new PaperSizeFormatWrapper(paperSize.PaperName, paperSize.Height, paperSize.Width));
            }

            if (printerSettings.IsValid)
                _isValid = Properties.ResourcesConstantsPrinter.IsValid;
            else
                _isValid = Properties.ResourcesConstantsPrinter.IsNotValid;

            if (_isDefault)
                _icon = new Uri("pack://application:,,/icons/gui/printerDefault.png");
            else
                _icon = new Uri("pack://application:,,/icons/gui/printer.png");

        }

        #endregion

        #region Methods
        #endregion
    }
}
